package com.yan.demo.demo7;

import java.util.ArrayList;

public class Tool {
    public Student getMaxStudent1(ArrayList<Student> list){
        Integer Max = list.get(0).getScore();
        Integer index = 0;
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).getScore() > Max){
                Max = list.get(i).getScore();
                index = i;
            }
        }
        return list.get(index);
    }

    public int getSum(ArrayList<Student>list){
        Integer sum = 0;
        for (int i = 0; i < list.size(); i++) {
            sum += list.get(i).getScore();
        }
        return sum;
    }

    public int getAvg(ArrayList<Student>list , Integer sum){
        return sum / list.size();
    }

    public void printFlunk(ArrayList<Student>list){
        Integer num = 0;
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).getScore() < 60){
                System.out.println(list.get(i));
                num++;
            }
        }
        System.out.println("不及格人数为:" + num);
    }
}
